package org.smartit.client.navigation;

import com.google.gwt.user.client.ui.Composite;
import org.smartit.client.ui.layout.RootPage;
import org.smartit.client.ui.pages.HomePage;

/**
 * TODO javadoc
 * Date: 24/11/13
 * Time: 17:39
 */
public class NavigationController {

    //In GWT, each tab in each browser the module runs under has its own version of static attribute
    private static NavigationController instance;

    //The pageContent at a specific moment
    private RootPage rootPage;

    public static NavigationController getInstance() {
        if (instance == null) {
            instance = new NavigationController();
        }
        return instance;
    }

    public NavigationController() {
        rootPage = new RootPage();
        setPageContent(new HomePage());
    }

    public RootPage getRootPage() {
        return rootPage;
    }

    public void setPageContent(Composite pageContent) {
        this.rootPage.setPageContent(pageContent, true);
    }

    public void setPageContentPopup(Composite pageContent) {
        this.rootPage.setPageContent(pageContent, false);
    }
}
